1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module shumate.MapSource; 26 27 private import gio.AsyncResultIF; 28 private import gio.Cancellable; 29 private import glib.ErrorG; 30 private import glib.GException; 31 private import glib.Str; 32 private import glib.c.functions; 33 private import gobject.ObjectG; 34 private import shumate.Tile; 35 private import shumate.c.functions; 36 public import shumate.c.types; 37 38 39 /** 40 * The base class for all map sources. Map sources fill [class@Tile] objects 41 * with images from various sources: a web API, for example, or a test pattern 42 * generated on demand. 43 * 44 * The most common map source is [class@RasterRenderer], which fetches tiles 45 * using a [class@TileDownloader]. 46 */ 47 public class MapSource : ObjectG 48 { 49 /** the main Gtk struct */ 50 protected ShumateMapSource* shumateMapSource; 51 52 /** Get the main Gtk struct */ 53 public ShumateMapSource* getMapSourceStruct(bool transferOwnership = false) 54 { 55 if (transferOwnership) 56 ownedRef = false; 57 return shumateMapSource; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)shumateMapSource; 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (ShumateMapSource* shumateMapSource, bool ownedRef = false) 70 { 71 this.shumateMapSource = shumateMapSource; 72 super(cast(GObject*)shumateMapSource, ownedRef); 73 } 74 75 76 /** */ 77 public static GType getType() 78 { 79 return shumate_map_source_get_type(); 80 } 81 82 /** 83 * Asynchronous version of shumate_map_source_fill_tile(). 84 * 85 * Params: 86 * tile = a #ShumateTile 87 * cancellable = a #GCancellable 88 * callback = a #GAsyncReadyCallback to execute upon completion 89 * userData = closure data for @callback 90 */ 91 public void fillTileAsync(Tile tile, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 92 { 93 shumate_map_source_fill_tile_async(shumateMapSource, (tile is null) ? null : tile.getTileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 94 } 95 96 /** 97 * Gets the success value of a completed shumate_map_source_fill_tile_async() 98 * operation. 99 * 100 * Params: 101 * result = a #GAsyncResult provided to callback 102 * 103 * Returns: %TRUE if the tile was filled with valid data, otherwise %FALSE 104 * 105 * Throws: GException on failure. 106 */ 107 public bool fillTileFinish(AsyncResultIF result) 108 { 109 GError* err = null; 110 111 auto __p = shumate_map_source_fill_tile_finish(shumateMapSource, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 112 113 if (err !is null) 114 { 115 throw new GException( new ErrorG(err) ); 116 } 117 118 return __p; 119 } 120 121 /** 122 * Gets the number of tiles in a column at this zoom level for this map 123 * source. 124 * 125 * Params: 126 * zoomLevel = the zoom level 127 * 128 * Returns: the number of tiles in a column 129 */ 130 public uint getColumnCount(uint zoomLevel) 131 { 132 return shumate_map_source_get_column_count(shumateMapSource, zoomLevel); 133 } 134 135 /** 136 * Gets map source's id. 137 * 138 * Returns: the map source's id. 139 */ 140 public string getId() 141 { 142 return Str.toString(shumate_map_source_get_id(shumateMapSource)); 143 } 144 145 /** 146 * Gets the latitude corresponding to this y position in the map source's 147 * projection. 148 * 149 * Params: 150 * zoomLevel = the zoom level 151 * y = a y position 152 * 153 * Returns: the latitude 154 */ 155 public double getLatitude(double zoomLevel, double y) 156 { 157 return shumate_map_source_get_latitude(shumateMapSource, zoomLevel, y); 158 } 159 160 /** 161 * Gets map source's license. 162 * 163 * Returns: the map source's license. 164 */ 165 public string getLicense() 166 { 167 return Str.toString(shumate_map_source_get_license(shumateMapSource)); 168 } 169 170 /** 171 * Gets map source's license URI. 172 * 173 * Returns: the map source's license URI. 174 */ 175 public string getLicenseUri() 176 { 177 return Str.toString(shumate_map_source_get_license_uri(shumateMapSource)); 178 } 179 180 /** 181 * Gets the longitude corresponding to this x position in the map source's 182 * projection. 183 * 184 * Params: 185 * zoomLevel = the zoom level 186 * x = a x position 187 * 188 * Returns: the longitude 189 */ 190 public double getLongitude(double zoomLevel, double x) 191 { 192 return shumate_map_source_get_longitude(shumateMapSource, zoomLevel, x); 193 } 194 195 /** 196 * Gets map source's maximum zoom level. 197 * 198 * Returns: the maximum zoom level this map source supports 199 */ 200 public uint getMaxZoomLevel() 201 { 202 return shumate_map_source_get_max_zoom_level(shumateMapSource); 203 } 204 205 /** 206 * Gets meters per pixel at the position on the map using this map source's projection. 207 * 208 * Params: 209 * zoomLevel = the zoom level 210 * latitude = a latitude 211 * longitude = a longitude 212 * 213 * Returns: the meters per pixel 214 */ 215 public double getMetersPerPixel(double zoomLevel, double latitude, double longitude) 216 { 217 return shumate_map_source_get_meters_per_pixel(shumateMapSource, zoomLevel, latitude, longitude); 218 } 219 220 /** 221 * Gets map source's minimum zoom level. 222 * 223 * Returns: the miminum zoom level this map source supports 224 */ 225 public uint getMinZoomLevel() 226 { 227 return shumate_map_source_get_min_zoom_level(shumateMapSource); 228 } 229 230 /** 231 * Gets map source's name. 232 * 233 * Returns: the map source's name. 234 */ 235 public string getName() 236 { 237 return Str.toString(shumate_map_source_get_name(shumateMapSource)); 238 } 239 240 /** 241 * Gets map source's projection. 242 * 243 * Returns: the map source's projection. 244 */ 245 public ShumateMapProjection getProjection() 246 { 247 return shumate_map_source_get_projection(shumateMapSource); 248 } 249 250 /** 251 * Gets the number of tiles in a row at this zoom level for this map source. 252 * 253 * Params: 254 * zoomLevel = the zoom level 255 * 256 * Returns: the number of tiles in a row 257 */ 258 public uint getRowCount(uint zoomLevel) 259 { 260 return shumate_map_source_get_row_count(shumateMapSource, zoomLevel); 261 } 262 263 /** 264 * Gets map source's tile size. 265 * 266 * Returns: the tile's size (width and height) in pixels for this map source 267 */ 268 public uint getTileSize() 269 { 270 return shumate_map_source_get_tile_size(shumateMapSource); 271 } 272 273 /** 274 * Gets the apparent size of the map tiles at the given fractional zoom level. 275 * 276 * As the map is zoomed in, a tile gets bigger and bigger until, at the next 277 * integer zoom level, it "splits" into four tiles at the next zoom level. 278 * Thus, the size increase follows an exponential curve, base 2. 279 * 280 * Params: 281 * zoomLevel = a zoom level 282 * 283 * Returns: the tile's size (width and height) in pixels for this map source 284 * at this zoom level 285 */ 286 public double getTileSizeAtZoom(double zoomLevel) 287 { 288 return shumate_map_source_get_tile_size_at_zoom(shumateMapSource, zoomLevel); 289 } 290 291 /** 292 * Gets the x position on the map using this map source's projection. 293 * (0, 0) is located at the top left. 294 * 295 * Params: 296 * zoomLevel = the zoom level 297 * longitude = a longitude 298 * 299 * Returns: the x position 300 */ 301 public double getX(double zoomLevel, double longitude) 302 { 303 return shumate_map_source_get_x(shumateMapSource, zoomLevel, longitude); 304 } 305 306 /** 307 * Gets the y position on the map using this map source's projection. 308 * (0, 0) is located at the top left. 309 * 310 * Params: 311 * zoomLevel = the zoom level 312 * latitude = a latitude 313 * 314 * Returns: the y position 315 */ 316 public double getY(double zoomLevel, double latitude) 317 { 318 return shumate_map_source_get_y(shumateMapSource, zoomLevel, latitude); 319 } 320 321 /** 322 * Sets the map source's id. 323 * 324 * Params: 325 * id = an id 326 */ 327 public void setId(string id) 328 { 329 shumate_map_source_set_id(shumateMapSource, Str.toStringz(id)); 330 } 331 332 /** 333 * Sets the map source's license. 334 * 335 * Params: 336 * license = the licence 337 */ 338 public void setLicense(string license) 339 { 340 shumate_map_source_set_license(shumateMapSource, Str.toStringz(license)); 341 } 342 343 /** 344 * Sets the map source's license URI. 345 * 346 * Params: 347 * licenseUri = the licence URI 348 */ 349 public void setLicenseUri(string licenseUri) 350 { 351 shumate_map_source_set_license_uri(shumateMapSource, Str.toStringz(licenseUri)); 352 } 353 354 /** 355 * Sets the map source's maximum zoom level. 356 * 357 * Params: 358 * zoomLevel = the maximum zoom level 359 */ 360 public void setMaxZoomLevel(uint zoomLevel) 361 { 362 shumate_map_source_set_max_zoom_level(shumateMapSource, zoomLevel); 363 } 364 365 /** 366 * Sets the map source's minimal zoom level. 367 * 368 * Params: 369 * zoomLevel = the minimal zoom level 370 */ 371 public void setMinZoomLevel(uint zoomLevel) 372 { 373 shumate_map_source_set_min_zoom_level(shumateMapSource, zoomLevel); 374 } 375 376 /** 377 * Sets the map source's name. 378 * 379 * Params: 380 * name = a name 381 */ 382 public void setName(string name) 383 { 384 shumate_map_source_set_name(shumateMapSource, Str.toStringz(name)); 385 } 386 387 /** 388 * Sets the map source's projection. 389 * 390 * Params: 391 * projection = a #ShumateMapProjection 392 */ 393 public void setProjection(ShumateMapProjection projection) 394 { 395 shumate_map_source_set_projection(shumateMapSource, projection); 396 } 397 398 /** 399 * Sets the map source's tile size. 400 * 401 * Params: 402 * tileSize = the tile size 403 */ 404 public void setTileSize(uint tileSize) 405 { 406 shumate_map_source_set_tile_size(shumateMapSource, tileSize); 407 } 408 }